#include "tools.h"
#include "WindowManager.h"
#include "Satory.h"
#include <QApplication>
#include "Crypter.h"
#include "json/json.h"
#include <QRegExpValidator>
bool IsEmail(const std::string mail)
{
    QRegExpValidator validator(QRegExp("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$"));

    int pos;
    QString email(mail.c_str());
    int ret= validator.validate(email,pos);
     return ret==QValidator::Acceptable;
}
#include <QDateTime>
int main(int argc, char *argv[])
{

    /*Crypter mCrypter,yourCrypter;
    DataBlock pass,iv,auth;
    DataBlock cipher,sign;
    mSession.GenRSAKeys(cipher,sign);
    mSession.GenAESKeys(pass,iv,auth);
    str mMessage="mycoolpassword";
    DataBlock message,encoded,decoded;
    message.CreateFrom((unsigned char*)mMessage.c_str(),mMessage.length()+1);

    mSession.encode(RSA,message,encoded);
    mSession.encode(AES,encoded,encoded);
    mSession.decode(AES,encoded,decoded);
    mSession.decode(RSA,decoded,decoded);
    str mRes((char*)decoded.Get());*/


    WindowManager a(argc, argv);
    a.ShowWindow(WindowManager::LOGINWINDOW);
    Sync::Create();
    Sync::AddRule(TLoginRequest)<<TVerifyRequest<<TResetKeyRequest<<TPrivateKeyGetRequest<<TRegisterRequest;
    Sync::AddRule(TResetKeyRequest)<<TVerifyRequest<<TLoginRequest<<TPrivateKeyGetRequest<<TRegisterRequest;
    Sync::AddRule(TPrivateKeyGetRequest)<<TVerifyRequest<<TResetKeyRequest<<TLoginRequest<<TRegisterRequest;
    Sync::AddRule(TRegisterRequest)<<TVerifyRequest<<TResetKeyRequest<<TPrivateKeyGetRequest<<TLoginRequest;
    Sync::AddRule(TVerifyRequest)<<TResetKeyRequest<<TPrivateKeyGetRequest<<TLoginRequest;





    Satory::Create();
    Satory::GetInstance()->InitDataFolder();
    //Satory::GetInstance()->SendMessage("{hello}");
    return a.exec();
}
